package sv.com.renacempleo.web.controller.ctg;

import net.sf.json.JSONArray;

import org.apache.commons.lang.StringUtils;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestParam;

import sv.com.renacempleo.web.controller.BaseController;
import sv.com.renacempleo.web.util.DBContext;
import sv.com.renacempleo.web.util.WebUtilidades;

public class CtgOficinaController extends BaseController{

	private static final long serialVersionUID = -5887179424406347701L;
	
	public String view(ModelMap model,
			@RequestParam (required = false) String header){
		model.addAttribute(WebUtilidades.HEADER_TITLE, StringUtils.isBlank(header) ? "OFICINAS" : header);
		try {
			model.put("data", JSONArray.fromObject(DBContext.getCtgOficinasDao().findAllAsArray()));
		} catch (Exception e) {
			logger.error("Exception",e);
		}
		return "admin/catalogo/ctgOficinas";
	}

}
